﻿
Partial Class Paginas_OComprasIngreso
    Inherits System.Web.UI.Page
    Dim myForm As String = "Form1"

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Page.IsPostBack = False Then
            xRespuesta.Text = "0"


            'Session("llamador") = Request.UrlReferrer.ToString()
            Imprimir.Attributes.Add("onclick", "print();")
            'Pagar.Attributes.Add("onclick", "if (!confirm('Está seguro de Confirmar Pago?')) return false")

            Dim ACCION As String = Request.QueryString("ACCION")
            Dim resultado As New DataSet
            Dim Rutinas As New DataServices.Rutinas

            Rutinas.load_cmb(nclinicaID, "select '' as campo1, ' Seleccione Clinica' as campo2 union all select ncodigo_pki as campo1, TNombreFantasia as campo2 from Empresas ", ACCION)

            ''******** cargar combo tipo de industria ******

            If ACCION <> "0" Then
                'Dim Csql As String = " SET LANGUAGE spanish; "
                'Csql = Csql & " select top 1 datename(m, '" & mes.Text & "') as campo1 from tbl_entidades"
                'resultado.Reset()
                'resultado = Rutinas.ExtraeSql(Csql)
                'mes.Text = resultado.Tables(0).Rows(0).Item(0)

                'Lee_Detalle()
                'Dim i As Integer

                ''For i = 0 To grilla.Items.Count - 1

                ''    Dim result2 As New DataSet
                ''    Csql = " select cuenta_cte as campo1, cuenta_cte as campo2 from TBL_Contabilizacion where banco_dep='" & DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).SelectedValue & "'"
                ''    result2.Reset()
                ''    result2 = Rutinas.ExtraeSql(Csql)
                ''    If Csql <> "" Then

                ''        If DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).SelectedValue > "0" Then
                ''            DirectCast(grilla.Items(i).Cells(12).Controls(1), DropDownList).DataSource = result2.Tables(0)
                ''            DirectCast(grilla.Items(i).Cells(12).Controls(1), DropDownList).DataValueField = "campo1"
                ''            DirectCast(grilla.Items(i).Cells(12).Controls(1), DropDownList).DataTextField = "campo2"
                ''            DirectCast(grilla.Items(i).Cells(12).Controls(1), DropDownList).DataBind()

                ''        End If
                ''    End If
                ''Next

            End If

            'Call Rutinas.Valida_Acceso(sender, e, Page, "Form1", Session("accesos"))

        End If

    End Sub
    Sub Lee_Detalle()

        Dim Rutinas As New DataServices.Rutinas
        Dim resp As Boolean
        Dim resultado As New DataTable
        Dim Rp As New DataServices.Rutinas
        Dim i As Integer
        Dim Csql As String = ""

        Csql = Csql & " select  convert(varchar(20),nitem_pki) as nitem_pk, 0 as campo1,a.ninterno_id as campo2, convert(varchar(10),b.demision,105) as campo3, a.tproducto as campo4, c.tnombre as campo5, fcantidad as campo6, fsaldo as campo7,'' campo8, '' campo9, '0' as proveedor"
        Csql = Csql & " from pedidosDetalle a join pedidosencabezado b on a.ninterno_id=b.ncodigo_pki join productos c on a.tproducto=c.ncodigo_pki"
        Csql = Csql & " where a.cestado=1 and a.fsaldo > 0 and b.nidempresa=" & nclinicaid.SelectedValue



        resp = Rp.Sp_ExecuteReader(resultado, Csql)

        ViewState("Grilla") = resultado
        grilla.DataSource = ViewState("Grilla")
        grilla.DataBind()

        'For i = 0 To ViewState("Grilla").Rows.Count - 1

        '***************agrega filas
        'Dim nuevaFila As DataRow
        'nuevaFila = ViewState("Grilla").NewRow()
        'nuevaFila("medio") = "0"
        'nuevaFila("banco") = 0
        'nuevaFila("ndoc") = ""
        'nuevaFila("fecha") = Format(Date.Now, "dd-MM-yyyy")
        'nuevaFila("bancod") = 0
        'nuevaFila("ctacte") = "0"

        'ViewState("Grilla").Rows.Add(nuevaFila)
        'grilla.DataSource = ViewState("Grilla")
        'grilla.DataBind()
        '************************+

        Dim result As New DataSet
        Csql = " select '0' as campo1, 'Seleccione' as campo2 union all select trut_pk as campo1, tnombres as campo2 from proveedores order by 2 "
        result.Reset()
        result = Rutinas.ExtraeSql(Csql)

        'Dim result1 As New DataSet
        'Csql = " select 0 as campo1, 'Seleccione' as campo2 union all select a.codigo as campo1, a.nombre as campo2 from TBL_PRIM_BANCOS as a,dbo.TBL_Contabilizacion as b where b.banco_dep=a.codigo"
        'result1.Reset()
        'result1 = Rutinas.ExtraeSql(Csql)


        For i = 0 To grilla.Items.Count - 1
            DirectCast(grilla.Items(i).Cells(9).Controls(1), DropDownList).DataSource = result.Tables(0)
            DirectCast(grilla.Items(i).Cells(9).Controls(1), DropDownList).DataValueField = "campo1"
            DirectCast(grilla.Items(i).Cells(9).Controls(1), DropDownList).DataTextField = "campo2"
            DirectCast(grilla.Items(i).Cells(9).Controls(1), DropDownList).SelectedValue = resultado.Rows(i).Item("proveedor")
            DirectCast(grilla.Items(i).Cells(9).Controls(1), DropDownList).DataBind()
            'DirectCast(grilla.Items(i).Cells(10).Controls(1), TextBox).Text = Format(Date.Now, "dd-MM-yyyy")
            'DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).DataSource = result1.Tables(0)
            'DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).DataValueField = "campo1"
            'DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).DataTextField = "campo2"
            'DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).SelectedValue = resultado.Rows(i).Item("bancod")
            'DirectCast(grilla.Items(i).Cells(11).Controls(1), DropDownList).DataBind()

        Next


        'grilla.Columns(2).ItemStyle.HorizontalAlign = HorizontalAlign.Left
        'grilla.Columns(6).ItemStyle.ForeColor = Color.SteelBlue
        'grilla.Columns(6).ItemStyle.BackColor = Color.WhiteSmoke
        'grilla.Columns(7).ItemStyle.ForeColor = Color.Black
        'grilla.Columns(7).ItemStyle.BackColor = Color.White
        'grilla.Columns(1).ItemStyle.ForeColor = Color.Black
        'grilla.Columns(1).ItemStyle.BackColor = Color.White
        'grilla.Columns(1).ItemStyle.Width = 100

        'For i = 0 To ViewState("Grilla").Rows.Count - 1
        '    If ViewState("Grilla").Rows(i).Item(1) = "0" Then
        '        grilla.Items.Item(i).ForeColor = Color.IndianRed 'Color.SteelBlue
        '        'grilla.Items.Item(i).BackColor = Color.IndianRed 'Color.WhiteSmoke
        '        grilla.Items.Item(i).Font.Bold = True
        '    End If

        '    If ViewState("Grilla").Rows(i).Item(0) = "TOTALES" Then
        '        grilla.Items.Item(i).ForeColor = Color.SteelBlue
        '        grilla.Items.Item(i).BackColor = Color.WhiteSmoke
        '        grilla.Items.Item(i).Font.Bold = True
        '        grilla.Items.Item(i).Cells(1).Enabled = False
        '        grilla.Items.Item(i).Cells(7).Visible = False
        '        grilla.Items.Item(i).Cells(8).Visible = False
        '        grilla.Items.Item(i).Cells(9).Visible = False
        '        grilla.Items.Item(i).Cells(10).Visible = False
        '        'grilla.Items.Item(i).Cells(11).Visible = False
        '        'grilla.Items.Item(i).Cells(12).Visible = False
        '        grilla.Items.Item(i).Cells(11).Visible = False

        '    End If
        'Next

    End Sub

    'Private Sub grilla_ItemCommand(ByVal source As Object, ByVal e As System.Web.UI.WebControls.DataGridCommandEventArgs) Handles grilla.ItemCommand
    '    Dim clave As String
    '    Dim scriptblock As String
    '    clave = DirectCast(e.Item.Cells(0).Controls(1), TextBox).Text
    '    Dim La_Accion As String = e.CommandName.ToString
    '    Dim fila As Integer = e.Item.ItemIndex

    '    clave = clave & "-" & ViewState("Grilla").Rows(fila).item("campo1") & "-" & DirectCast(grilla.Items(fila).Cells(4).Controls(1), TextBox).Text & "-" & DirectCast(grilla.Items(fila).Cells(7).Controls(1), DropDownList).SelectedValue & "-" & DirectCast(grilla.Items(fila).Cells(9).Controls(1), TextBox).Text & "-" & DirectCast(grilla.Items(fila).Cells(8).Controls(1), DropDownList).SelectedValue & "-" & DirectCast(grilla.Items(fila).Cells(10).Controls(1), TextBox).Text & "-" & xmes.Text & "-" & xanio.Text
    '    scriptblock = "<script language='javascript'>AbrirPago('" & clave & "');</script>"
    '    Page.RegisterStartupScript("Launch_Report_Window", scriptblock)
    '    Session("fila") = fila

    'End Sub

    Sub GRABAR(ByRef mensaje As String)

        Dim resultado As New DataSet
        Dim Rutinas As New DataServices.Rutinas
        Dim i As Integer
        Dim Csql As String
        Dim scriptblock As String
        xError.Visible = False

        Try

            mensaje = ""


            For i = 0 To ViewState("Grilla").Rows.Count - 1

                If DirectCast(grilla.Items(i).Cells(1).Controls(1), CheckBox).Checked = True Then

                    If DirectCast(grilla.Items(i).Cells(8).Controls(1), TextBox).Text = "" Then
                        mensaje = "<script language='javascript'>alert('En fila " & i + 1 & " se debe ingresar Cantidad. ');</script>"
                        Exit Sub
                    End If

                    If DirectCast(grilla.Items(i).Cells(9).Controls(1), TextBox).Text = "" Then
                        mensaje = "<script language='javascript'>alert('En fila " & i + 1 & " se debe ingresar Precio. ');</script>"
                        Exit Sub
                    End If

                    Dim saldo As Double

                    saldo = Val(DirectCast(grilla.Items(i).Cells(7).Controls(1), Label).Text) - Val(DirectCast(grilla.Items(i).Cells(8).Controls(1), TextBox).Text)

                    If saldo < 0 Then
                        mensaje = "<script language='javascript'>alert('En fila " & i + 1 & " la cantidad es mayor que el saldo restante. ');</script>"
                        Exit Sub
                    End If


                    Dim clave As String

                    clave = DirectCast(grilla.Items(i).Cells(1).Controls(1), TextBox).Text
                    Dim estado As Integer = 1
                    If saldo = 0 Then
                        estado = 2
                    End If
                    'Rutinas.EjecutarSql("update PedidosDetalle set nestado=" & estado & ",fsaldo=" & saldo & " where  nitem_pk=" & clave & " ")



                    '        If DirectCast(grilla.Items(i).Cells(8).Controls(1), DropDownList).SelectedValue = "0" Then
                    '            mensaje = "<script language='javascript'>alert('Se debe ingresar dato en Banco Pagador. ');</script>"
                    '            Exit Sub
                    '        End If

                    '        If DirectCast(grilla.Items(i).Cells(9).Controls(1), TextBox).Text = " " Then
                    '            mensaje = "<script language='javascript'>alert('Se debe ingresar dato en N° Documento. ');</script>"
                    '            Exit Sub
                    '        End If

                    '        If DirectCast(grilla.Items(i).Cells(10).Controls(1), TextBox).Text = " " Then
                    '            mensaje = "<script language='javascript'>alert('Se debe ingresar dato en Fecha Documento. ');</script>"
                    '            Exit Sub
                    '        End If

                    '    End If


                    '    Dim valor1 As String = Replace(IIf(IsDBNull(ViewState("Grilla").Rows(i).item("campo2")), 0, ViewState("Grilla").Rows(i).item("campo2")), ".", "")
                    '    Dim valor2 As String = Replace(DirectCast(grilla.Items(i).Cells(4).Controls(1), TextBox).Text, ".", "")
                    '    Dim valor3 As Double = Val(valor2) - Val(valor1)
                    '    Dim nItem_Pk As Integer = ViewState("Grilla").Rows(i).item("nitem_pk")
                    '    Dim banco As Integer = DirectCast(grilla.Items(i).Cells(8).Controls(1), DropDownList).SelectedValue

                    '    If valor2 = "" Then
                    '        valor2 = 0
                    '    End If

                    '    Rutinas.EjecutarSql(" UPDATE TBL_PRIMAPAG_Detalle SET Monto_Pagado='" & valor2 & "' WHERE codigo_CSV=3023 and FK_PRIMAPAG_Cabecera=" & nItem_Pk)

                    '    Csql = " select count(*) from dbo.TBL_PRIM_MPAGO where FK_primapag_cabecera=" & nItem_Pk
                    '    resultado.Reset()
                    '    resultado = Rutinas.ExtraeSql(Csql)
                    '    Dim codigo As Integer = IIf(IsDBNull(resultado.Tables(0).Rows(0).Item(0)), " ", resultado.Tables(0).Rows(0).Item(0))

                    '    Dim Parametros(7) As Object
                    '    Parametros(0) = nItem_Pk
                    '    Parametros(1) = DirectCast(grilla.Items(i).Cells(7).Controls(1), DropDownList).SelectedValue
                    '    Parametros(2) = banco
                    '    Parametros(3) = DirectCast(grilla.Items(i).Cells(9).Controls(1), TextBox).Text
                    '    Parametros(4) = DirectCast(grilla.Items(i).Cells(10).Controls(1), TextBox).Text
                    '    Parametros(7) = codigo

                    '    Dim rp As New diabetes_lilas.ResponseValidator("", "")
                    '    rp.ExecuteDataset("SP_PRIM_MPAGO", Parametros)

                    '    If Not rp.Errores Then
                    '        rp.Commit()
                    '        resultado = rp.Dataset
                    '    Else
                    '        Dim mensajeBD As String = rp.Mensaje
                    '        xError.Visible = True
                    '        xError.Text = mensajeBD
                    '    End If
                    '    rp.Dispose()
                End If
            Next

            'Lee_Detalle()

        Catch ex As Exception

            xError.Visible = True
            xError.Text = ex.Message
        End Try


    End Sub



    Private Sub Modificar_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Modificar.Click
        'Dim fila As Integer = Session("fila")
        Dim scriptblock As String
        xError.Visible = False

        Dim mensaje As String = ""

        Try
            Call GRABAR(mensaje)

            If mensaje <> "" Then
                Page.RegisterStartupScript("Launch_Report_Window", mensaje)
                Exit Sub
            End If

        Catch ex As Exception

            xError.Visible = True
            xError.Text = ex.Message
        End Try


    End Sub

    'Protected Sub Pagar_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Pagar.Click
    '    Dim resultado As New DataSet
    '    Dim Rutinas As New DataServices.Rutinas
    '    Dim strscript As String
    '    Dim pagado As String
    '    Dim Csql As String
    '    Dim nItem_Pk As Integer
    '    Dim i As Integer
    '    Dim valor As String







    '    Dim mensaje As String = ""
    '    xError.Visible = False


    '    Call GRABAR(mensaje)

    '    If mensaje <> "" Then
    '        Page.RegisterStartupScript("Launch_Report_Window", mensaje)
    '        Exit Sub
    '    End If


    '    If xRespuesta.Text = "1" Then
    '        xRespuesta.Text = "0"
    '        Exit Sub
    '    End If

    '    If xRespuesta.Text = "2" Then
    '        For i = 0 To ViewState("Grilla").Rows.count - 1
    '            Try
    '                nItem_Pk = ViewState("Grilla").Rows(i).item("nitem_pk")
    '                Rutinas.EjecutarSql(" UPDATE TBL_PRIMAPAG_Cabecera SET Estado=4 WHERE Estado=1 and ID_PRIMAPAG_Cabecera=" & nItem_Pk)

    '            Catch ex As Exception
    '                xError.Visible = True
    '                xError.Text = ex.Message
    '            End Try
    '        Next

    '        xRespuesta.Text = "0"

    '        Modificar.Visible = False
    '        Pagar.Enabled = False
    '        Pagar.ImageUrl = "../botones/pago_over.gif"
    '        xestado.Text = "Pagado"

    '        Dim destino As String
    '        destino = "alert('Registro Actualizado');"
    '        Dim scriptblock1 As String = "<script language='javascript'>" & destino & "</script>"
    '        Page.RegisterStartupScript("Launch_Report_Window", scriptblock1)
    '        Exit Sub
    '    End If



    '    Try

    '        Dim mensaje1 As String = "Seguro de Confirmar Pago?"
    '        Dim ceros As Integer = 0
    '        For i = 0 To ViewState("Grilla").Rows.count - 1
    '            If Replace(DirectCast(grilla.Items(i).Cells(4).Controls(1), TextBox).Text, ".", "") = 0 And ViewState("Grilla").Rows(i).Item(0) <> "TOTALES" Then
    '                ceros = ceros + 1
    '            End If
    '        Next

    '        If ceros > 0 Then
    '            mensaje1 = "Existen valores en cero. " & mensaje1
    '        End If

    '        Dim scriptblock As String = "<script language='javascript'>DialogoAceptar('" & mensaje1 & "');</script>"
    '        Page.RegisterStartupScript("Launch_Report_Window", scriptblock)

    '    Catch ex As Exception
    '        xError.Visible = True
    '        xError.Text = ex.Message
    '    End Try

    'End Sub

    Protected Sub Excel_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Excel.Click

        Dim resultado As New DataSet
        Dim Rutinas As New DataServices.Rutinas

        'Dim Csql As String = " SELECT B.TNOMBRE as campo1,dbo.Fn_Format(isnull(convert(numeric,A.Monto_Primas),'0'),0) as campo2,dbo.Fn_Format(isnull(convert(numeric,A.Monto_Pagado),'0'),0) as campo3,dbo.Fn_Format(isnull(convert(numeric,A.Monto_Cuadratura),'0'),0) as campo4,C.ID_PRIMAPAG_Cabecera as nitem_pk, dbo.Fn_Format(isnull(convert(numeric,A.Monto_Pagado),'0') - isnull(convert(numeric,A.Monto_Primas),'0'),0) as resto, isnull(d.medio_pago,0) as medio, isnull(d.banco_pag,0) as banco, isnull(d.ndoc,'') as ndoc, isnull(d.fecha,'') as fecha"
        'Csql = Csql & " FROM dbo.TBL_PRIMAPAG_Detalle AS A, dbo.TBL_Entidades AS B, dbo.TBL_PRIMAPAG_Cabecera AS C"
        'Csql = Csql & " left outer join dbo.TBL_PRIM_MPAGO as D on d.FK_PRIMAPAG_Cabecera=C.ID_PRIMAPAG_Cabecera "
        'Csql = Csql & " WHERE A.Codigo_CSV=3023 AND C.Codigo_IDENTIFICACION=B.TCODIGO AND A.FK_PRIMAPAG_Cabecera=C.ID_PRIMAPAG_Cabecera AND substring(convert(varchar(6),C.Mes_informado),1,4)='" & xanio.Text & "' AND substring(convert(varchar(6),C.Mes_informado),5,2)='" & xmes.Text & "'"
        'Csql = Csql & " union all"
        'Csql = Csql & " SELECT 'TOTALES' as campo1,dbo.Fn_Format(sum(isnull(convert(numeric,A.Monto_Primas),'0')),0) as campo2,dbo.Fn_Format(sum(isnull(convert(numeric,A.Monto_Pagado),'0')),0) as campo3,dbo.Fn_Format(sum(isnull(convert(numeric,A.Monto_Cuadratura),'0')),0) as campo4,'0' as nitem_pk, dbo.Fn_Format(sum(isnull(convert(numeric,A.Monto_Pagado),'0') - isnull(convert(numeric,A.Monto_Primas),'0')),0) as resto, 0 as medio, 0 as banco, '' as ndoc, '' as fecha"
        'Csql = Csql & " FROM dbo.TBL_PRIMAPAG_Detalle AS A, dbo.TBL_Entidades AS B, dbo.TBL_PRIMAPAG_Cabecera AS C"
        'Csql = Csql & " WHERE A.Codigo_CSV=3023 AND C.Codigo_IDENTIFICACION=B.TCODIGO AND A.FK_PRIMAPAG_Cabecera=C.ID_PRIMAPAG_Cabecera AND substring(convert(varchar(6),C.Mes_informado),1,4)='" & xanio.Text & "' AND substring(convert(varchar(6),C.Mes_informado),5,2)='" & xmes.Text & "'"

        'resultado = Rutinas.ExtraeSql(Csql)
        'If resultado.Tables.Count = 0 Then
        '    Dim scriptblock As String = "<script language='javascript'>alert('No existe la información requerida. ');</script>"
        '    Page.RegisterStartupScript("Launch_Report_Window", scriptblock)
        '    Exit Sub
        'End If

        'ViewState("Grilla") = resultado
        'grilla.DataSource = ViewState("Grilla")
        'grilla.DataBind()

        'grilla.Columns(2).ItemStyle.HorizontalAlign = HorizontalAlign.Left
        'grilla.Columns(7).ItemStyle.HorizontalAlign = HorizontalAlign.Left
        'grilla.Columns(8).ItemStyle.HorizontalAlign = HorizontalAlign.Left
        'grilla.Columns(9).ItemStyle.HorizontalAlign = HorizontalAlign.Center
        'grilla.Columns(10).ItemStyle.HorizontalAlign = HorizontalAlign.Center

        'Dim DataGrid2 As DataGrid = New DataGrid

        'DataGrid2 = grilla
        'DataGrid2.Columns(0).Visible = False
        'DataGrid2.Columns(1).Visible = False
        'DataGrid2.Columns(13).Visible = False

        'Arma_Excel()
        ''Dim exp As New DataServices.Utilidades.ExportarExcel
        ''exp.Exportar(DataGrid2, Response)
        ''exp.Dispose()

    End Sub

    Sub Arma_Excel()

        Dim filename As String = "Datos"
        Response.Clear()
        Response.AddHeader("content-disposition", "attachment;filename=" & filename & ".xls")
        Response.Charset = ""
        Me.EnableViewState = False
        Response.Cache.SetCacheability(HttpCacheability.NoCache)
        Response.ContentType = "application/vnd.xls"

        Dim htmlWrite As System.Web.UI.HtmlTextWriter = New HtmlTextWriter(Response.Output)

        'Dim myDataGrid As New DataGrid()
        'myDataGrid.DataSource = dsReport.Tables(1)
        'myDataGrid.DataBind()
        grilla.RenderControl(htmlWrite)

        Response.End()

    End Sub

    'Public Sub mostrar_cambio(ByVal sender As Object, ByVal e As System.EventArgs)

    '    Dim Rutinas As New DataServices.Rutinas
    '    Dim dgItem As DataGridItem
    '    Dim gridItem As DataGridItem = sender.Parent.Parent
    '    Dim clave As Integer = gridItem.ItemIndex
    '    'Dim selected As DropDownList = DirectCast(sender, DropDownList)

    '    For Each dgItem In grilla.Items

    '        Dim fila As Integer = dgItem.ItemIndex
    '        If clave = fila Then

    '            Dim result2 As New DataSet
    '            Dim Csql As String = " select '0' as campo1, 'Seleccione' as campo2 union all select cuenta_cte as campo1, cuenta_cte as campo2 from TBL_Contabilizacion where banco_dep='" & DirectCast(grilla.Items(fila).Cells(11).Controls(1), DropDownList).SelectedValue & "'"
    '            result2.Reset()
    '            result2 = Rutinas.ExtraeSql(Csql)
    '            If Csql <> "" Then

    '                If DirectCast(grilla.Items(fila).Cells(11).Controls(1), DropDownList).SelectedValue > "0" Then
    '                    DirectCast(grilla.Items(fila).Cells(12).Controls(1), DropDownList).DataSource = result2.Tables(0)
    '                    DirectCast(grilla.Items(fila).Cells(12).Controls(1), DropDownList).DataValueField = "campo1"
    '                    DirectCast(grilla.Items(fila).Cells(12).Controls(1), DropDownList).DataTextField = "campo2"
    '                    DirectCast(grilla.Items(fila).Cells(12).Controls(1), DropDownList).DataBind()

    '                End If
    '            End If
    '        End If
    '    Next

    'End Sub

    Protected Sub Salir_Click(ByVal sender As Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles Salir.Click
        Response.Redirect(Session("llamador"))
    End Sub


   
    Protected Sub nclinicaid_SelectedIndexChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles nclinicaid.SelectedIndexChanged
        Lee_Detalle()

    End Sub
End Class
